Byte
A low-level, zero-copy and panic-free binary serializer and deserializer.
Documentation
Usage
Add the following to your Cargo.toml
:
[]
= "0.2"
Byte
is a no_std
library; it can be used in any #![no_std]
situation or crate.
Overview
Byte
is designed to encode or decode binary data in a fast and low-level way.
A classical use case is I2C communication en/decoding.
Byte
provides two core traits TryRead
and TryWrite
.
Types that implement these traits can be serialized into or deserialized from byte slices.
The library is meant to be simple, and it will always be.
Example
use *;
let bytes: & = &;
let offset = &mut 0;
let num = bytes..unwrap;
assert_eq!;
assert_eq!;
use *;
use ;
let bytes: & = b"hello, world!\0dump";
let offset = &mut 0;
let str = bytes..unwrap;
assert_eq!;
assert_eq!;
Contribution
All kinds of contribution are welcomed.
- Issues. Feel free to open an issue when you find typos, bugs, or have any question.
- Pull requests. New collection, better implementation, more tests, more documents and typo fixes are all welcomed.
License
Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)